package interfaces.menu.joinGame.filters;

import interfaces.menu.joinGame.gamesTable.GamesTableWidget;
import interfaces.options.TextEditorOptionWidget;

public class PlayersFilter extends Filter {
	
	private TextEditorOptionWidget textEditor;
	private boolean min;
	
	public PlayersFilter(TextEditorOptionWidget filterWidget, boolean min) {
		super(filterWidget);
		this.min = min;
		
		textEditor = filterWidget;
	}
	
	@Override
	public boolean passes(GamesTableWidget widget) {
		int players = widget.getPlayers().size();
		int value = Integer.valueOf(textEditor.getValue()).intValue();
		return min ? (players >= value) : (players <= value);
	}
}